package com.zhou.juc.test13_Interview;

import java.util.concurrent.locks.LockSupport;

/**
 * @author zhouyanxiang
 * @create 2020-08-2020/8/17-20:26
 */
public class T02_00_LockSupport {

    static Thread t1 = null,t2  = null;

    public static void main(String[] args) {

        char[] aI  = "123456".toCharArray();
        char[] aC  = "ABCDEF".toCharArray();

        t1 = new Thread(()->{
            for(char ch: aI){
                System.out.print(ch);
                LockSupport.unpark(t2);
                LockSupport.park();
            }
        });

        t2 = new Thread(()->{
            for (char c : aC){
                LockSupport.park();
                System.out.print(c);
                LockSupport.unpark(t1);
            }
        });

        t1.start();
        t2.start();
    }

}
